home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / DBio / ureadseq.h < prev   
Text File  |  1996-07-05  |  6KB  |  243 lines

  1. /* File: ureadseq.h
  2.  *
  3.  * Header for module UReadSeq
  4.  */
  5.  
  6. #ifndef UREADSEQ_H
  7. #define UREADSEQ_H
  8.  
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12.  
  13. #ifndef boolean
  14. #ifdef _NCBI_
  15. #define boolean Nlm_Boolean
  16. #else
  17. typedef unsigned char boolean;
  18. #endif
  19. #endif
  20.  
  21. #ifndef false
  22. #define false 0
  23. #endif
  24. #ifndef true
  25. #define true  1
  26. #endif
  27.  
  28. #ifndef NEWLINE
  29. #define NEWLINE         '\n'
  30. #endif
  31. #ifndef min
  32. #define min(a,b)      (a<b)?a:b
  33. #endif
  34. #ifndef max
  35. #define max(a,b)      (a>b)?a:b
  36. #endif
  37. #ifndef skipwhitespace
  38. #define skipwhitespace(string)  {while (*string <= ' ' && *string != 0) string++;}
  39. #endif
  40.  
  41.   /* NLM strings */
  42. #ifndef is_upper
  43. #define is_upper(c) ('A'<=(c) && (c)<='Z')
  44. #endif
  45. #ifndef is_lower
  46. #define is_lower(c) ('a'<=(c) && (c)<='z')
  47. #endif
  48. #ifndef to_lower
  49. #define to_lower(c) ((char)(is_upper(c) ? (c)+' ' : (c)))
  50. #endif
  51. #ifndef to_upper
  52. #define to_upper(c) ((char)(is_lower(c) ? (c)-' ' : (c)))
  53. #endif
  54.  
  55.  
  56.   /* readSeq errors */
  57. #define eFileNotFound   -1
  58. #define eNoData         -2
  59. #define eMemFull        -3
  60. #define eItemNotFound   -4
  61. #define eOneFormat      -5
  62. #define eUnequalSize    -6
  63. #define eFileCreate     -7
  64. #define eUnknownFormat  -8
  65. #define eOptionBad      -9
  66. #define eASNerr         -10
  67.  
  68.   /* magic number for readSeq(whichEntry) to give seq list */
  69. #define kListSequences  -1
  70.  
  71.  
  72.     /* name space collisions !! damn defines */
  73. #ifdef UREADSEQ_G
  74.  
  75.   /* sequence types parsed by getseqtype */
  76. #define kOtherSeq   0
  77. #define kDNA        1
  78. #define kRNA        2
  79. #define kNucleic    3
  80. #define kAmino      4
  81.  
  82.   /* formats known to readSeq */
  83. #define kIG             1
  84. #define kGenBank        2
  85. #define kNBRF           3
  86. #define kEMBL           4
  87. #define kGCG            5
  88. #define kStrider        6
  89. #define kFitch          7
  90. #define kPearson        8
  91. #define kZuker          9
  92. #define kOlsen          10
  93. #define kPhylip2        11
  94. #define kPhylip4        12
  95. #define kPhylip3        kPhylip4
  96. #define kPhylip         kPhylip4
  97. #define kPlain          13  /* keep this at #13 */
  98. #define kPIR            14
  99. #define kMSF            15
  100. #define kASN1           16
  101. #define kPAUP           17
  102. #define kPretty         18
  103.  
  104. #define kMaxFormat      18
  105. #define kMinFormat      1
  106. #define kNoformat       -1    /* format not tested */
  107. #define kUnknown        0     /* format not determinable */
  108.  
  109.   /* subsidiary types */
  110. #define kASNseqentry    51
  111. #define kASNseqset      52
  112.  
  113. #define kPhylipInterleave 61
  114. #define kPhylipSequential 62
  115.  
  116.  
  117. #define kRSFile_Eof            1
  118. #define kRSFile_Read        2
  119. #define kRSFile_Write        3
  120. #define kRSFile_Seek        4
  121. #define kRSFile_Rewind    5
  122. #define kRSFile_Tell        6
  123. #define kRSFile_End            7
  124.  
  125. #endif
  126.  
  127.  
  128. typedef struct {
  129.   boolean isactive, baseonlynum,
  130.         numright, numleft, numtop, numbot,
  131.         nameright, nameleft, nametop,
  132.         noleaves, domatch, degap;
  133.   char  matchchar, gapchar;
  134.   short numline, atseq,
  135.         namewidth, numwidth,
  136.         interline, spacer, seqwidth, tab;
  137.   } prettyopts;
  138.  
  139.  
  140. #define gPrettyInit(p) { \
  141.   p.isactive=false;\
  142.   p.baseonlynum=true;\
  143.   p.numline= p.atseq= 0;\
  144.   p.numright= p.numtop= true; \
  145.   p.numleft= p.numbot= false;\
  146.   p.nameright= true; \
  147.   p.nameleft= p.nametop= false;\
  148.   p.noleaves= p.domatch= p.degap= false;\
  149.   p.matchchar='.';\
  150.   p.gapchar='-';\
  151.   p.namewidth=8;\
  152.   p.numwidth=5;\
  153.   p.interline=1;\
  154.   p.spacer=10;\
  155.   p.seqwidth=50;\
  156.   p.tab=0; }
  157.  
  158. #ifdef UREADSEQ_G
  159. prettyopts  gPretty;
  160. #else
  161. extern  prettyopts  gPretty;
  162. #endif
  163.  
  164. #ifdef TRANSLATE
  165. #ifdef UREADSEQ_G
  166. char  gTranslate[256];
  167. #else
  168. extern char  gTranslate[256];
  169. #endif
  170. #define gTranslateInit() { short c; for(c=0; c<256; c++) gTranslate[c]= c; }
  171. #endif
  172.  
  173.  
  174. typedef  long (*ReadWriteProc)( char* line, long maxline, short action);
  175.  
  176. extern short seqFileFormat(const char *filename, long *skiplines, short *error );
  177. extern short seqFileFormatFp(FILE *fseq, long  *skiplines, short *error );
  178. extern short seqFileFormatCall(ReadWriteProc reader, long *skiplines, short *error );
  179.  
  180. extern char *listSeqs(const char *filename, const long skiplines,
  181.                        const short format, short *nseq, short *error );
  182.                                              
  183. extern char *listSeqsCall(ReadWriteProc reader, const long skiplines,
  184.                        const short format, short *nseq, short *error );
  185.  
  186.  
  187. extern char *readSeq(const short whichEntry, const char *filename,
  188.                       const long skiplines, const short format,
  189.                       long *seqlen, short *nseq, short *error, char *seqid );
  190.  
  191. extern char *readSeqFp(const short whichEntry, FILE  *fp,
  192.                                      const long  skiplines, const short format,
  193.                                long  *seqlen,  short *nseq, short *error, char *seqid );
  194.  
  195. extern char *readSeqCall(const short whichEntry, ReadWriteProc reader,
  196.                       const long skiplines, const short format,
  197.                       long *seqlen, short *nseq, short *error, char *seqid );
  198.  
  199.  
  200.                                 
  201. extern short writeSeq(FILE *outf, const char *seq, const long seqlen,
  202.                        const short outform, const char *seqid );
  203.  
  204. extern short writeSeqCall(ReadWriteProc writer, const char *seq, const long seqlen,
  205.                 const short outform, const char *seqid);
  206.  
  207. extern unsigned long CRC32checksum(const char *seq, const long seqlen, unsigned long *checktotal);
  208. extern unsigned long GCGchecksum(const char *seq, const long seqlen, unsigned long *checktotal);
  209.  
  210. #ifdef SMALLCHECKSUM
  211. #define seqchecksum  GCGchecksum
  212. #else
  213. #define seqchecksum  CRC32checksum
  214. #endif
  215.  
  216. extern short getseqtype(const char *seq, const long seqlen );
  217. extern void GetSeqStats( const char* seq, const long seqlen, 
  218.                             short* seqtype, unsigned long* checksum, long* basecount);
  219. extern char *compressSeq( const char gapc, const char *seq, const long seqlen, long *newlen);
  220.  
  221.  
  222. #ifdef NCBI
  223.  
  224. extern char *listASNSeqs(const char *filename, const long skiplines,
  225.                   const short format, short *nseq, short *error );
  226.  
  227. extern char *readASNSeq(const short whichEntry, const char *filename,
  228.                 const long skiplines, const short format,
  229.                 long *seqlen, short *nseq, short *error, char **seqid );
  230. #endif
  231.  
  232.  
  233.   /* patches for some missing string.h stuff */
  234. /* extern int Strcasecmp(const char *a, const char *b); */
  235. /* extern int Strncasecmp(const char *a, const char *b, long maxn); */
  236.  
  237. #ifdef __cplusplus
  238. }
  239. #endif
  240.  
  241. #endif /*UREADSEQ_H*/
  242.  
  243.